package com.star.commonlib.utils.timer

import java.util.*

/**
 *  @des: 正向计时器
 *  @author: sam
 *  @date: 2021/1/18
 */
fun startTimer(delay: Long, duration: Long, timerChanged: TimerChanged): Timer {
    val timer = Timer()
    val timerTask = object : TimerTask() {
        override fun run() {
            //为其它线程
            timerChanged.onTimerChanged()
        }
    }
    timer.schedule(timerTask, delay, duration)
    return timer
}

interface TimerChanged {
    fun onTimerChanged()
}
